<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:include href="../admin.xsl" />
	<xsl:include href="../cp/path.xsl" />
	
	<!-- Запускаем рендер страницы -->
	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
		</head>
		<body>
			<xsl:call-template name="admin-header" />
			
			<div id="blocks">
				<div id="blocks_inner" />
			</div>
			
			<div id="content">
				<div id="content_inner">
					<xsl:apply-templates select="response" />
				</div>
			</div>
			
			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	<xsl:template match="response">
		<div id="path">
			<xsl:apply-templates select="document('xmodule://cp/getPath/0;blogs;posts_types')/data/response" mode="cp-path" />
		</div>
		
		<h1>Типы публикаций</h1>
		
		<xsl:apply-templates select="message" />
		<xsl:apply-templates select="error" />
		
		<form action="{$baseURI}/admin/blogs/add_post_type" method="post">
			<select name="type">
				<option value="">-- выберите тип</option>
				
				<xsl:for-each select="document('xmodule://system/getTypes')/data/response/object[@type='explay_type']">
					<option value="{@id}">
						<xsl:value-of select="property[@name='title']/value" />
					</option>
				</xsl:for-each>
			</select>
			<input type="submit" value="добавить тип" />
		</form>

		<p />
		
		<table class="standart" cellspacing="0" cellpadding="0">
			<tbody>
				<tr>
					<th>Тип</th>
					<th>Опции</th>
				</tr>
				
				<xsl:apply-templates select="object[@type='post_type']" />
			</tbody>
		</table>
	</xsl:template>
	
	<xsl:template match="object[@type='post_type']">
		<tr>
			<td>
				<xsl:value-of select="@type-title" />
			</td>
			<td>
				<a href="{$baseURI}/admin/blogs/delete_post_type/{@id}?scode={$scode}" onclick="if(!confirm('Вы действительно хотите удалить этот тип публикаций?'))return false;">удалить</a>
			</td>
		</tr>
	</xsl:template>
	
</xsl:stylesheet>